/*
 * Student.java
 *
 * Created on 12 February 2007, 23:00
 */

package eu.expressis.eiaf.auth.infrastructure.integration.db.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import eu.expressis.eiaf.core.infrastructure.integration.db.entity.AbstractEntity;

/**
 *
 * @author Sergio
 */
@Entity
public class Student extends AbstractEntity{
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
   
    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name="username")
    private User userAccount;
    
    private String firstName;
    private String lastName;
    private int yearOfStudy;
    private String email;
    
    /** Creates a new instance of Student */
    public Student(String firstName, String lastName, int yearOfStudy, String email) {
        this.setFirstName(firstName);
        this.setLastName(lastName);
        this.setYearOfStudy(yearOfStudy);
        this.setEmail(email);
    }
    
    public Student() {
    }
    
    public Long getId() {
        return id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }
    
    public String getFirstName() {
        return firstName;
    }
    
    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }
    
    public String getLastName() {
        return lastName;
    }
    
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    
    public int getYearOfStudy() {
        return yearOfStudy;
    }
    
    public void setYearOfStudy(int yearOfStudy) {
        this.yearOfStudy = yearOfStudy;
    }
    
    public String getEmail() {
        return email;
    }
    
    public void setEmail(String email) {
        this.email = email;
    }

    public User getUserAccount() {
        return userAccount;
    }

    public void setUserAccount(User userAccount) {
        this.userAccount = userAccount;
    }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Student other = (Student) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}
    
    
}
